package com.rabbitmq.logisticsservice.controller;

import com.rabbitmq.logisticsservice.constant.Constants;
import com.rabbitmq.orderservice.model.OrderMessageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.tomcat.util.bcel.Const;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 物流系统接收消息
 */
//@RequestMapping("/logistics")
//@RestController
@Component
@Slf4j
@RabbitListener(queues = Constants.ORDER_QUEUE)
public class LogisticsController {

    @Autowired
    private RabbitTemplate rabbitTemplate;

//    @RequestMapping("/receiveMessage")
    @RabbitHandler
    public void receiveOrderMessage(String orderMessage) {
        log.info("物流接收到消息, String: {}", orderMessage);

//        return "消息接收成功";
    }

    //根据消息类型转换格式
    //同类型的方法只能有一个
    @RabbitHandler
    public void receiveOrderMessage(OrderMessageInfo orderMessage) {
        log.info("物流接收到消息, OrderMessageInfo: {}", orderMessage);

//        return "消息接收成功";
    }
}
